package weaver.conn;

import java.sql.Array;
import java.sql.Blob;
import java.sql.CallableStatement;
import java.sql.Clob;
import java.sql.Connection;
import java.sql.DatabaseMetaData;
import java.sql.NClob;
import java.sql.PreparedStatement;
import java.sql.SQLClientInfoException;
import java.sql.SQLException;
import java.sql.SQLWarning;
import java.sql.SQLXML;
import java.sql.Savepoint;
import java.sql.Statement;
import java.sql.Struct;
import java.util.Map;
import java.util.Properties;
import java.util.concurrent.Executor;
import weaver.conn.WeaverPreparedStatement;
import weaver.conn.WeaverStatement;
import weaver.general.BaseBean;
import weaver.monitor.monitor.MonitorConn;

public class WeaverConnection implements Connection {
    private Connection conn;

    private String dbtype = "";

    private String orgindbtype = "";

    private boolean isConvertSort = false;

    public String getOrgindbtype() {
        return this.orgindbtype;
    }

    public void setOrgindbtype(String paramString) {
        this.orgindbtype = paramString;
    }

    public WeaverConnection(Connection paramConnection) {
        this.conn = paramConnection;
        this.dbtype = "";
    }

    public void setDBType(String paramString) {
        this.dbtype = paramString;
    }

    public String getDBType() {
        return this.dbtype;
    }

    public void useConnection() {}

    public boolean isRelease() {
        return true;
    }

    public boolean isUse() {
        return false;
    }

    public int useCount() {
        return 0;
    }

    public boolean isValidate() {
        return true;
    }

    public long getTimeStamp() {
        return 0L;
    }

    public void release() {
        try {
            if (this.conn != null)
                this.conn.close();
        } catch (SQLException sQLException) {
            (new BaseBean()).writeLog(sQLException);
        }
    }

    public void close() {
        if (this.dbtype.toLowerCase().equals("oracle"))
            try {
                this.conn.commit();
            } catch (Exception exception) {}
        release();
    }

    public void onlyClose() {
        try {
            MonitorConn.removeConn(this);
        } catch (Exception exception) {}
        release();
    }

    protected Connection getConnection() {
        return this.conn;
    }

    public PreparedStatement prepareStatement(String paramString) throws SQLException {
        return (PreparedStatement)new WeaverPreparedStatement(this, paramString);
    }

    public PreparedStatement originPreparedStatement(String paramString) throws SQLException {
        return (PreparedStatement)new WeaverPreparedStatement(this, paramString, false);
    }

    public Map getTypeMap() throws SQLException {
        return this.conn.getTypeMap();
    }

    public PreparedStatement prepareStatement(String paramString, int paramInt1, int paramInt2) throws SQLException {
        return (PreparedStatement)new WeaverPreparedStatement(this.conn, paramString, paramInt1, paramInt2);
    }

    public CallableStatement prepareCall(String paramString) throws SQLException {
        return this.conn.prepareCall(paramString);
    }

    public CallableStatement prepareCall(String paramString, int paramInt1, int paramInt2) throws SQLException {
        return this.conn.prepareCall(paramString, paramInt1, paramInt2);
    }

    public Statement createStatement() throws SQLException {
        return (Statement)new WeaverStatement(this, this.conn.createStatement());
    }

    public Statement createStatement(int paramInt1, int paramInt2) throws SQLException {
        return (Statement)new WeaverStatement(this, this.conn.createStatement(paramInt1, paramInt2));
    }

    public String nativeSQL(String paramString) throws SQLException {
        return this.conn.nativeSQL(paramString);
    }

    public void setAutoCommit(boolean paramBoolean) throws SQLException {
        this.conn.setAutoCommit(paramBoolean);
    }

    public boolean getAutoCommit() throws SQLException {
        return this.conn.getAutoCommit();
    }

    public void commit() throws SQLException {
        if (!this.conn.getAutoCommit())
            this.conn.commit();
    }

    public void rollback() throws SQLException {
        this.conn.rollback();
    }

    public boolean isClosed() throws SQLException {
        return this.conn.isClosed();
    }

    public DatabaseMetaData getMetaData() throws SQLException {
        return this.conn.getMetaData();
    }

    public void setReadOnly(boolean paramBoolean) throws SQLException {
        this.conn.setReadOnly(paramBoolean);
    }

    public boolean isReadOnly() throws SQLException {
        return this.conn.isReadOnly();
    }

    public void setCatalog(String paramString) throws SQLException {
        this.conn.setCatalog(paramString);
    }

    public String getCatalog() throws SQLException {
        return this.conn.getCatalog();
    }

    public void setTransactionIsolation(int paramInt) throws SQLException {
        this.conn.setTransactionIsolation(paramInt);
    }

    public int getTransactionIsolation() throws SQLException {
        return this.conn.getTransactionIsolation();
    }

    public SQLWarning getWarnings() throws SQLException {
        return this.conn.getWarnings();
    }

    public void clearWarnings() throws SQLException {
        this.conn.clearWarnings();
    }

    public void setHoldability(int paramInt) throws SQLException {
        this.conn.setHoldability(paramInt);
    }

    public int getHoldability() throws SQLException {
        return this.conn.getHoldability();
    }

    public Statement createStatement(int paramInt1, int paramInt2, int paramInt3) throws SQLException {
        return (Statement)new WeaverStatement(this, this.conn.createStatement(paramInt1, paramInt2, paramInt3));
    }

    public PreparedStatement prepareStatement(String paramString, int paramInt1, int paramInt2, int paramInt3) throws SQLException {
        return (PreparedStatement)new WeaverPreparedStatement(this, paramString, paramInt1, paramInt2, paramInt3);
    }

    public CallableStatement prepareCall(String paramString, int paramInt1, int paramInt2, int paramInt3) throws SQLException {
        return this.conn.prepareCall(paramString, paramInt1, paramInt2, paramInt3);
    }

    public PreparedStatement prepareStatement(String paramString, int paramInt) throws SQLException {
        return (PreparedStatement)new WeaverPreparedStatement(this, paramString, paramInt);
    }

    public PreparedStatement prepareStatement(String paramString, int[] paramArrayOfint) throws SQLException {
        return (PreparedStatement)new WeaverPreparedStatement(this, paramString, paramArrayOfint);
    }

    public PreparedStatement prepareStatement(String paramString, String[] paramArrayOfString) throws SQLException {
        return (PreparedStatement)new WeaverPreparedStatement(this, paramString, paramArrayOfString);
    }

    public Array createArrayOf(String paramString, Object[] paramArrayOfObject) throws SQLException {
        return this.conn.createArrayOf(paramString, paramArrayOfObject);
    }

    public Blob createBlob() throws SQLException {
        return this.conn.createBlob();
    }

    public Clob createClob() throws SQLException {
        return this.conn.createClob();
    }

    public NClob createNClob() throws SQLException {
        return this.conn.createNClob();
    }

    public SQLXML createSQLXML() throws SQLException {
        return this.conn.createSQLXML();
    }

    public Struct createStruct(String paramString, Object[] paramArrayOfObject) throws SQLException {
        return this.conn.createStruct(paramString, paramArrayOfObject);
    }

    public Properties getClientInfo() throws SQLException {
        return this.conn.getClientInfo();
    }

    public String getClientInfo(String paramString) throws SQLException {
        return this.conn.getClientInfo(paramString);
    }

    public boolean isValid(int paramInt) throws SQLException {
        return this.conn.isValid(paramInt);
    }

    public void releaseSavepoint(Savepoint paramSavepoint) throws SQLException {
        this.conn.releaseSavepoint(paramSavepoint);
    }

    public void rollback(Savepoint paramSavepoint) throws SQLException {
        this.conn.rollback(paramSavepoint);
    }

    public void setClientInfo(Properties paramProperties) throws SQLClientInfoException {
        this.conn.setClientInfo(paramProperties);
    }

    public void setClientInfo(String paramString1, String paramString2) throws SQLClientInfoException {
        this.conn.setClientInfo(paramString1, paramString2);
    }

    public Savepoint setSavepoint() throws SQLException {
        return this.conn.setSavepoint();
    }

    public Savepoint setSavepoint(String paramString) throws SQLException {
        return this.conn.setSavepoint(paramString);
    }

    public void setTypeMap(Map<String, Class<?>> paramMap) throws SQLException {
        this.conn.setTypeMap(paramMap);
    }

    public boolean isWrapperFor(Class<?> paramClass) throws SQLException {
        return this.conn.isWrapperFor(paramClass);
    }

    public <T> T unwrap(Class<T> paramClass) throws SQLException {
        return this.conn.unwrap(paramClass);
    }

    public void setSchema(String paramString) throws SQLException {
        this.conn.setSchema(paramString);
    }

    public String getSchema() throws SQLException {
        return this.conn.getSchema();
    }

    public void abort(Executor paramExecutor) throws SQLException {
        this.conn.abort(paramExecutor);
    }

    public void setNetworkTimeout(Executor paramExecutor, int paramInt) throws SQLException {
        this.conn.setNetworkTimeout(paramExecutor, paramInt);
    }

    public int getNetworkTimeout() throws SQLException {
        return this.conn.getNetworkTimeout();
    }

    public void setConvertSort(boolean paramBoolean) {
        this.isConvertSort = paramBoolean;
    }

    public boolean isConvertSort() {
        return this.isConvertSort;
    }
}
